<?php
/**
 * 微信用户操作类
 * User: narnia
 * Date: 2017/5/19
 * Time: 11:24
 */
namespace LancerWechat;
class WechatUser extends WechatService
{
    public $key = 'user';
    /**
     * @var 用户信息
     */
    public $user;


    /**
     * 获取用户信息
     * @return mixed|null
     */
    public function getUser(string $openid)
    {
        $result = null;
        if ($openid) {
            $url = $this->getUrl([
                '{access_token}' => $this->config['global']['access_token'],
                '{openid}' => $openid
            ], [$this->key, 'get']);
            $result = json_decode(\LancerWechat\WechatFunction::curl($url));
        }
        \LancerWechat\WechatLog::write($this->config['log']['path'], $result);
        return $result;
    }

}